package com.ly.algorithm.DataStructures.sort;

import java.util.Date;
import java.util.Random;

/**
 * @Classname SelectSort
 * @Description TODO
 * @Date 2020/4/24 10:47
 * @Author 冷心影翼
 */
public class SelectSort {

    public static void main(String[] args) {
//        int[] arr = {3,202,-21,23,34,34,56,7,13,23,77};

        int[] arr = new int[80000];

        Random random = new Random();
        for(int i=0;i<80000;i++) {
            arr[i] =  random.nextInt(80000);
        }

        Date date1 = new Date();
        for(int i=0;i<arr.length-1;i++) {
            int min = arr[i];
            int minIndex = i;
            for (int j = i; j < arr.length-1; j++) {
                if(arr[j] < min) {
                    min = arr[j];
                    minIndex = j;
                }
            }
//            if(minIndex!=i) {
                arr[minIndex] = arr[i];
                arr[i] = min;
//            }

        }
        Date date2 = new Date();
        System.out.println(date2.getTime()-date1.getTime());
//        System.out.println(Arrays.toString(arr));
    }
}
